<?php

namespace app\api\controller;

use app\admin\model\GoodsOrder;
use app\common\controller\Api;
use think\Env;

/**
 *  我的订单接口
 */
class Order extends Api
{
    protected $noNeedLogin = ['*'];
    protected $noNeedRight = ['*'];


    /**
     * 订单列表
     *
     */
    public function index()
    {
        $model = new GoodsOrder();
        $status = input('status/d');
        $data['goods_order.user_id'] = $this->auth->id;
        $data = $model->where(['goods_order.status' => $status])->with(['goods'])
            ->field('goods_order.id,order_num,pay_price')
            ->select();
        foreach ($data as &$v) {
            $v['goods_title'] = $v->goods->title;
            $v['goods_score'] = $v->goods->score;
            $v['goods_image'] = Env::get('app.yuming') . $v->goods->image;
            unset($v->goods);
        }
        $this->success('获取成功', $data, 1);

    }
}
